﻿using System;
using System.Windows.Forms;
using bbtpClient.Entities;
using bbtpClient.Controllers;

namespace bbtpClient
{
    public partial class ChooseGoodForm : Form
    {
        private long goodId;

        public long GoodId
        {
            get { return goodId; }
            set { goodId = value; }
        }


        public ChooseGoodForm(GoodHead[] goods)
        {
            InitializeComponent();
            goods_listBox.Items.AddRange(goods);
        }

        private void chooseGood_button_Click(object sender, EventArgs e)
        {
            int selectedGoodIndex = goods_listBox.SelectedIndex;
            GoodHead goodHead = (GoodHead)goods_listBox.Items[selectedGoodIndex];
            goodId = goodHead.id;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void cancel_button_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}